package com.xilihui.xlh.business.widget;

import android.app.Activity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup.LayoutParams;
import android.widget.PopupWindow;
import android.widget.TextView;

import com.xilihui.xlh.R;
import com.xilihui.xlh.core.util.ToastUtil;
import com.xilihui.xlh.core.util.YEventBuses;

/**
 * Created by Administrator on 2018/5/18.
 */

public class JifengPopWindow extends PopupWindow implements View.OnClickListener {
    
    public static final String JIFENG = "jifeng";
    
    private View view;
    private TextView tv_changyong;
    private TextView tv_juli;
    private TextView tv_pingfei;
    
    
    public JifengPopWindow(Activity context){

        view = LayoutInflater.from(context).inflate(R.layout.popup_jifeng,null);
        initView();
        this.setContentView(view);
        this.setWidth(LayoutParams.WRAP_CONTENT);
        this.setHeight(LayoutParams.WRAP_CONTENT);
        this.setFocusable(true);
        this.setOutsideTouchable(true);
        this.setAnimationStyle(R.style.AnimationPreview);
        
    }
    
    public void initView(){
        
        tv_changyong = (TextView)view.findViewById(R.id.tv_changyong);
        tv_juli = (TextView)view.findViewById(R.id.tv_juli);
        tv_pingfei = (TextView)view.findViewById(R.id.tv_pingfen);
        
        tv_changyong.setOnClickListener(this);
        tv_juli.setOnClickListener(this);
        tv_pingfei.setOnClickListener(this);
        
    }
    
    public void show(View view){
        if(view!=null){
            showAsDropDown(view,0,-20);
        }
    }


    @Override
    public void onClick(View view) {
        dismiss();
        switch (view.getId()){
            case R.id.tv_changyong:
                ToastUtil.toastShortPositive("全部");
                YEventBuses.post(new YEventBuses.Event(JIFENG).setParams("10086"));
                break;
            case R.id.tv_juli:
                ToastUtil.toastShortPositive("获取");
                YEventBuses.post(new YEventBuses.Event(JIFENG).setParams("1"));
                break;
            case R.id.tv_pingfen:
                ToastUtil.toastShortPositive("使用");
                YEventBuses.post(new YEventBuses.Event(JIFENG).setParams("2"));
                break;
        }
    }
    
    
}
